package com.smh.aiagent.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.advisor.RetrievalAugmentationAdvisor;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.ai.rag.retrieval.search.VectorStoreDocumentRetriever;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.vectorstore.filter.FilterExpressionBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shiminghui
 * @date 2025/6/3 16:46
 * @description: 文档检索Advisor
 */
@Configuration
public class LoveAppDocumentRetrieverAdvisorConfig {

    @Resource
    private VectorStore pgVectorStore;

    @Bean
    public Advisor loveAppDocumentRetrieverAdvisor() {
        return RetrievalAugmentationAdvisor
                .builder()
                .documentRetriever(VectorStoreDocumentRetriever
                        .builder()
                        .similarityThreshold(0.5)
                        .topK(5)
                        .vectorStore(pgVectorStore)
                        .filterExpression(new FilterExpressionBuilder().eq("status", "已婚").build())
                        .build())
                .build();
    }

}
